{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="user_name" class="layui-input search" name="user_name" value="" placeholder="标题"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <select name="nt_fid" lay-search="">
                                <option value="">不限足球篮球</option>
                                <option value="1">足球</option>
                                <option value="2">篮球</option>
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <select name="nt_type" lay-search="">
                                <option value="">不限赛事推荐类型</option>
                                <option value="1">自动分配</option>
                                <option value="2">手动分配</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button class="btn btn-primary" type="button" onclick="wk.layer_show('新建', '{:url('typeAdd')}')">
                            <i class="fa fa-plus"></i> 添加
                        </button>
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--图片显示模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.new_thumb}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="nt_fid">
                    {{# if(d.nt_fid == 1){ }}
                    足球
                    {{# } }}
                    {{# if(d.nt_fid == 2){ }}
                    篮球
                    {{# } }}
                    </script>
                    <script type="text/html" id="nt_one">
                    {{# if(d.nt_type == 1){ }}
                    --
                    {{# }else{ }}
                        {{# if(d.match1){ }}
                            {{d.nt_one}}：
                            {{d.match1.mf_name}}|
                            {{d.match1.mf_match_time}}|
                            {{d.match1.mf_home_name_cn}} vs
                            {{d.match1.mf_away_name_cn}}
                        {{# }else{ }}
                            未配置
                        {{# } }}
                    {{# } }}
                    </script>
                    <script type="text/html" id="nt_two">
                    {{# if(d.nt_type == 1){ }}
                    --
                    {{# }else{ }}
                        {{# if(d.match2){ }}
                            {{d.nt_two}}：
                            {{d.match2.mf_name}}|
                            {{d.match2.mf_match_time}}|
                            {{d.match2.mf_home_name_cn}} vs
                            {{d.match2.mf_away_name_cn}}
                        {{# }else{ }}
                            未配置
                        {{# } }}
                    {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        {{# if(d.nt_type == 2){ }}
                        <a href="javascript:;" onclick="wk.layer_show('分配赛事', '{:url('setMatch')}?nt_id={{d.nt_id}}')" class="btn btn-primary btn-xs m-r-xs" title="分配赛事">分配赛事</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.layer_show('编辑/详情', '{:url('typeEdit')}?nt_id={{d.nt_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑/详情">编辑/详情</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.nt_id}}','{:url('typeDel')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("News/types")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left'}
                  {type:'numbers', width: 70, title: '序号'}
                , {field: 'nt_id', width: '70', title: 'id', align: 'center'}
                , {field: 'nt_name', width: '100', title: '分类名字', align: 'center'}
                , {field: 'nt_fid', width: 80, title: '类型', align: 'center',templet: '#nt_fid'}
                , {field: 'typename', width: '', title: '赛事推荐类型', align: 'center'}
                , {field: 'nt_sort', width: '110', title: '排序值', sort: true,align: 'center'}
                , {field: 'nt_one', width: '', title: '赛事1', align: 'center',templet: '#nt_one'}
                , {field: 'nt_two', width: '', title: '赛事2', align: 'center',templet: '#nt_two'}
                , {field: 'nt_time', width: '100', title: '发布时间', align: 'center'}
                , {fixed: 'right', width:220, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAllNoSelect($('#allidsForOut').val(),$('.layui-input').serialize(),"{:url('outExcel')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>